import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart'hide Action;
import 'package:school_safe_teacher/resourse/app_colors.dart';

import 'action.dart';
import 'state.dart';

Reducer<SuggestState> buildReducer() {
  return asReducer(
    <Object, Reducer<SuggestState>>{
      SuggestAction.action: _onAction,
    },
  );
}

SuggestState _onAction(SuggestState state, Action action) {
  final SuggestState newState = state.clone();
  if (newState.suggestType == 1) {
    newState
      ..type2TextColor = AppColors.deepTextColor
      ..type2BgColor = AppColors.MainBackColor
      ..type1TextColor = Colors.white
      ..type1BgColor = AppColors.GuideBtnTextColor;
  }else{
    newState
      ..type1TextColor = AppColors.deepTextColor
      ..type1BgColor = AppColors.MainBackColor
      ..type2TextColor = Colors.white
      ..type2BgColor = AppColors.GuideBtnTextColor;
  }
  if(newState.content.isNotEmpty){
    newState
      ..loginTextColor = Colors.white
      ..loginBtnStartColor = AppColors.loginLeft
      ..loginBtnEndColor = AppColors.loginRight
      ..canSubmit = true;
  }else{
    newState
      ..loginTextColor = AppColors.cantClickTextColor
      ..loginBtnStartColor = AppColors.loginBtnColor
      ..loginBtnEndColor = AppColors.loginBtnColor
      ..canSubmit = false;
  }
  return newState;
}
